<?php if (@$type == "optional"){ ?>

<script>
    $(function(){
        
		/* REMOVE DUPLICATE ID */
		var ids = [];
		$('*').each(function() {
		    if (this.id && this.id !== '') {
		        if (ids[this.id]) {
		            $(this).remove();
		        } else {
		            ids[this.id] = this
		        }
		    }
		});
        
        function format(state) {
			tambahan = "";
			if (typeof $(state.element[0]).attr("alt") != "undefined")
				tambahan = $(state.element[0]).attr("alt");
            return state.text+tambahan ; 
        }
        
		$.fn.getCombobox = function(data, key, label, desc){
			var field = $(this);
			field.html("<option></option>");
			$.ajax({
				url : "c_public_function",
				data : data,
				type : 'POST', dataType : 'json'
			}).done(function(response){
				for(i=0;i<response.length;i++){
					var option = "<option value='"+response[i][key]+"' ";
					if (typeof response[i][desc] != "undefined")
						option += " alt='<div class=desc>"+response[i][desc]+"</div>'";
						
					option += " >"+response[i][label]+"</option>";
					field.append(option);
				}
				
				field.select2({
					placeholder: "-",
					allowClear: true,
					formatResult: format,
					formatSelection: format,
					escapeMarkup: function (m) {
						return m;
					}
				});
			});
		}
		
		$.fn.serializeObject = function()
		{
		   var o = {};
		   var a = this.serializeArray();
		   $.each(a, function() {
			   if (o[this.name]) {
				   if (!o[this.name].push) {
					   o[this.name] = [o[this.name]];
				   }
				   o[this.name].push(this.value || '');
			   } else {
				   o[this.name] = this.value || '';
			   }
		   });
		   return o;
		};
        
        var field_pekerjaan_id = $("#pekerjaan_id");
        var field_bulan = $("#bulan");
        var btnview = $("#btn-view");
        
		field_pekerjaan_id.getCombobox({task : "pekerjaan"}, "pekerjaan_id", "pekerjaan_ket");
        field_bulan.datepicker({ format : ' MM yyyy', autoclose : true});
        btnview.click(function(){
            $(".html").load("c_laporan",{task : "map_mandor", type : "filter" , pekerjaan_id : field_pekerjaan_id.val(), bulan : field_bulan.val()});
        });
    });
</script>
	<div class="portlet box blue" tabindex="-1" >
	   <div class="portlet-title">
		  <div class="caption"><i class="icon-reorder"></i>Form Filter</div>
		  <div class="tools">
			 <a href="javascript:;" class="collapse"></a>
		  </div>
	   </div>

		<div class="portlet-body form">
            
            <form class="horizontal-form" onSubmit="javascript:return false;" >
                
			 <div class="form-body">
            <div class="row"><div class="col-md-6"><div class="form-group"><label class="control-label">Pekerjaan Yang Ditangani:</label><select id="pekerjaan_id" name="pekerjaan_id" class="form-control" multiple /></div></div>
                
                </div></div>
                
                 <div class="form-actions right">
                    <button type="submit" id="btn-view" class="btn blue"><i class="icon-ok"></i> View</button>
                 </div>
                
            </form>

	   </div>
	</div>
<?php }else{ ?>

<div style="float:left"><img src="<?php echo base_url("../assets/images/ptpp.jpg") ?>" style="width:200px;"></div>
<div style="width:100%"><h3 style="text-align:center;">Mapping Mandor
<br /><i>PT. PP (Persero) DVO III</i>
<!-- <br /><i>November 2014</i> -->
</h3>
</div>
    <br clear=both>
<table class="print table table-bordered  ">
    <thead>
        <tr >
            <th rowspan="1">No</th>
            <th rowspan="1">Nama Mandor</th>
            <th rowspan="1">Kode Vendor</th>
            <th rowspan="1">No HP</th>
            <th rowspan="1">Kota</th>
            <th rowspan="1">Status</th>
            <th rowspan="1">Cabang</th>
            <th rowspan="1">Kode</th>
            <th rowspan="1">Proyek</th>
            <th rowspan="1">Pekerjaan</th>
            <th rowspan="1">Kelas</th>
            <th rowspan="1">Tukang</th>
            <th rowspan="1">Pekerja</th>
            <th rowspan="1">KMK/Reguler</th>
            <th rowspan="1">Asal</th>
            <th rowspan="1">Koordinasi</th>
            <th rowspan="1">Quality</th>
            <th rowspan="1">Safety</th>
            <th rowspan="1">K(lingk)</th>
        </tr>
    </thead>
    <tbody>
        
<?php
    $i = 0;
    foreach($data as $row){
        $i++;
        
     /*   foreach($arr_kemampuan as $pekerjaan_id){
            $kemampuan[] =  $arr_pekerjaan[$pekerjaan_id];
        }
       $kemampuan = implode(", <br />",$kemampuan); 
       */
        
        echo "
        <tr>
            <td >".$i."</td>
            <td >".$row->mandor_nama."</td>
            <td >".$row->mandor_kode."</td>
            <td >".$row->mandor_telpon."</td>
            <td >".$row->mandor_kota."</td>
            <td >".$row->mandor_status."</td>
            <td >".$row->cabang_nama."</td>
            <td >$row->proyek_kode</td>
            <td >$row->proyek_nama</td>
            <td >$row->pekerjaan_ket</td>
            <td >$row->proyek_kelas</td>
            <td >".($row->mandor_tukang1 + $row->mandor_tukang1 )."</td>
            <td >$row->mandor_pekerja</td>
            <td >$row->pendanaan_ket</td>
            <td >-</td>
            <td >$row->monitor_koordinasi</td>
            <td >$row->monitor_quality</td>
            <td >$row->monitor_safety</td>
            <td >$row->monitor_hk</td>
        </tr>
    ";
    }
?>
    </tbody>
</table>

<?php } ?>
